package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-16
 * Time: 10:42
 */
class Shape{
    public void draw(){
        System.out.println("画一个图形");
    }
}
class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个原圆");
    }
}
class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个矩形");
    }
}
class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个三角形");
    }
}
public class Test2 {
    public static void main(String[] args) {
        Cycle cycle = new Cycle();
        Rect rect = new Rect();
        Triangle triangle = new Triangle();
        String[] strings = {"cycle","cycle", "react", "react","triangle","triangle"};
        for(String s : strings){
            if(s.equals(cycle)){
                cycle.draw();
            }else if(s.equals(rect)){
                rect.draw();
            }else{
                triangle.draw();
            }
        }
    }
}
    /*Shape[] shapes = {cycle, cycle, rect,rect,triangle,triangle};
        for(Shape shape : shapes){
                shape.draw();
                }*/